<script setup lang="ts">
  import { ref, watch } from 'vue';
  import { addUser, getOrgAll } from '@/api/syssetting';
  import { FormInstance, Message } from '@arco-design/web-vue';
  import useLoading from '@/hooks/loading';
  const formRef = ref<FormInstance | null>(null);
  const props = defineProps({
    visible: Boolean,
    formType: Array,
  });
  const { loading, setLoading } = useLoading();
  defineOptions({
    name: 'userEditSetting',
  });
  const formData = ref({
    user_dept_id: '', //用户id
    user_name: '', //用户名称
    user_true_name: '', //真实姓名
    user_password: '', //用户密码
    user_confirm_password: '', //确认密码
    user_mobile: '', //用户手机
    user_wechat: '', //用户微信
    user_gender: '', //用户性别
    user_sort: '', //用户排序
    user_remarks: '', //备注信息
    role_ids: [], //角色id
  });
  const emit = defineEmits(['update:visible', 'refresh']);

  const handleSubmit = async () => {
    if (!(await formRef.value?.checkForm())) {
      try {
        setLoading(true);
        const res = await addUser(formRef.value?.formModel);
        Message.success(res.msg);
        emit('update:visible', false);
        setLoading(false);
        emit('refresh');
      } catch (error) {
        setLoading(false);
      }
    } else {
      Message.error('请正确填写表单！');
    }
  };
</script>

<template>
  <a-modal
    title="批量导入档案"
    :visible="visible"
    @ok="handleSubmit"
    title-align="start"
    :ok-loading="loading"
    @cancel="
      () => {
        emit('update:visible', false);
      }
    "
  >
    <a-row> 示例导入模版： <a-link href="link">综合档案模板</a-link> </a-row>
    <a-row style="margin-top: 20px"> <a-upload draggable action="/" /> </a-row>
  </a-modal>
</template>

<style scoped lang="less">
  :deep(.arco-select-view-inner) {
    text-align: left !important;
  }
</style>
